import java.sql.SQLOutput;


public class j3 {
    public static int sum(int n){
        if (n<10){
            System.out.println(n);

        }
        sum(n/10);
        System.out.println(n%10);
    }

    public static void main0(String[] args) {
        System.out.println(sum(1729));

    }
    /*利用递归打印求1-10累计和*/
    /*public static int sum(int n){
        if (n==0){
            return 0;
        }
        return n+(sum (n-1));
    }
    public static void main8(String[] args) {
        int ret=sum(10);
        System.out.println(ret);
    }
   *//*利用递归打印1,2,3*//*
    public static void print(int n){
        if (n<10){
            System.out.println(n);
            return;
        }
        print(n/10);
        System.out.println(n%10);
    }
    public static void main7(String[] args) {
        print(123);
    }*/
    /*方法重载（方法名一样，返回参数不一样(个数，类型，顺序)任何一种都可以）*/
    public static double add(int c,double d){
        return c+d;
    }
    public static double add(double c,int d){
        return d+c;
    }
    public static void main6(String[] args) {

        int c=3;
        double d=4;
        double ret1=add(c,d);
        double ret2=add(c,d);
        System.out.println(ret1);
        System.out.println(ret2);

    }
    /*5函数定义两个整数相加*/
    public static int add (int a,int b){
        return  a+ b;
    }
    public static void main5(String[] args) {
        int a=10;
        int b=20;
        int ret=add(a,b);
        System.out.println(ret);
    }
    /*4函数定义判断输入年份是否为闰年*/
    public static boolean leapyear(int year){
        if ((year%4==0 && year %100!=0) || year % 400 == 0){
            return true;
        }
        else {
            return false;
        }
    }

    public static void main4(String[] args) {
        boolean ret=leapyear(2020);
        if (ret==true){
            System.out.println("是闰年");
        }
        else{
            System.out.println("不是闰年");
        }
    }
    /*1while if 循环嵌套，统计1 - 100中个位是9或者十位是9的数字个数*/
    public static void main1(String[] args) {
        int i=1;
        int count=0;
        while(i<=100){
            if (i%10==9) {
                count++;
            }
            if(i/10==9){
                count++;
            }
            i++;
        }
        System.out.println(count);
    }

    /*1 for if 循环嵌套，统计1 - 100中个位是9或者十位是9的数字个数*/
    public static void main2(String[] args) {
        int count=0;
        for (int i = 1; i <=100 ; i++) {
            if(i%10==9){
                count++;
            }
                if(i/10==9){
                     count++;
            }
        }
        System.out.println(count);
    }

    /*2 for if 循环嵌套，判断素数*/
    public static void main3(String[] args) {
        int n = 7;
        int i = 2;
        for (i = 2; i <= Math.sqrt(n); i++) {
            if (n % i == 0) {
                break;
            }
        }
            if (i > Math.sqrt(n)) {
                System.out.println(n + "是素数");

            }

    }
}
